import { getToken ,getUserId} from '@/utils/auth'
const state = {
  userName: '',
  token: getToken(),
  userId: getUserId(),
}
const mutations = {
  SET_USER_NAME(state, name) {
    state.userName = name
  },
  SET_TOKEN: (state, token) => {
    state.token = token
  },
  SET_USER_ID: (state, userId) => {
    state.userId = userId
  },
}
const actions = {
  // 设置name
  setUserName({ commit }, name) {
    commit('SET_USER_NAME', name)
  },
  setToken({ commit }, name) {
    commit('SET_TOKEN', name)
  },
  setUserId({ commit }, name) {
    commit('SET_USER_ID', name)
  }
}
export default {
  state,
  mutations,
  actions
}
